<style>
    .custom-toolbar{padding: 0em 1em 1em 0em;}
</style>
<div class="row-fluid clearfix">
    <div class="col-md-12 column">
        <ul class="breadcrumb">
            <li>
                <a href="index.html">首页</a>
            </li>
            <li class="active">
                客户信息管理
            </li>
        </ul>
    </div>
    <div class="col-md-12 column">
        <div class="col-sm-12 div-page">
            <div class="col-sm-12 div-table">
                <div id="custom-toolbar" class="col-sm-12 custom-toolbar">

                </div>
                <table id="table" class="table table-hover table-condensed"
                       data-click-to-select="true"  data-single-select="true" data-height="410">
                    <thead>
                    <tr>
                        <th data-field="state" data-checkbox="true" ></th>
                        <th data-field="OrgName" data-halign="center" data-align="center" data-width="150">归属机构</th>
                        <th data-field="UseName" data-halign="center" data-align="center" data-width="150">客户姓名</th>
                        <th data-field="DeviceId" data-halign="center" data-align="center" data-width="200">终端编号</th>
                        <th data-field="SafeDevId" data-halign="center" data-align="center" data-width="200">安全设备号</th>
                        <th data-field="CertifiNo" data-halign="center" data-align="center" data-width="200">证件号码</th>
                        <th data-field="CartNo" data-halign="center" data-align="center" data-width="200">绑定卡号</th>
                        <th data-field="CreatTime" data-halign="center" data-align="center" data-width="150">开户日期</th>
                        <th data-field="Tel_StateText" data-halign="center" data-align="center" data-width="150">终端状态</th>
                        <th data-field="UserTypeText" data-halign="center" data-align="center" data-width="150">用户类型</th>
                        <th data-field="Phone" data-halign="center" data-align="center" data-width="150">联系电话</th>
                        <th data-field="InstallAddr" data-halign="center" data-align="center" data-width="500">布放地址</th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="col-sm-12 alert alert-success div-alert" id="events-result" data-es="Aquí se muestra el resultado del evento"></div>
        <!-- #筛选条件遮罩层 --->
        <div class="modal fade" id="modal-Filter" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <div class="modal-title" id="myModalLabel1">
                            筛选条件
                        </div>
                    </div>
                    <form id="queryForm" method="post" class="form-horizontal layer_msg">
                        <div class="modal-body">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">所属机构</label>
                                <div class="col-sm-8">
                                    <input type="hidden" class="form-control" name="OrgId" id="OrgId"/>
                                    <input type="hidden" class="form-control" id="OrgName"/>
                                    <div class="col-sm-4" style="padding-left: 0;padding-right: 2px">
                                        <select class="form-control" id="level1">
                                        </select>
                                    </div>
                                    <div class="col-sm-4" style="padding-left: 0;padding-right: 2px;display: none">
                                        <select class="form-control" id="level2">
                                        </select>
                                    </div>
                                    <div class="col-sm-4" style="padding-left: 0;padding-right: 0;display: none">
                                        <select class="form-control" id="level3">
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">客户姓名</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="UseName"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">证件号码</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="CertifiNo"/>
                                </div>
                            </div>
                            <div class="form-group hidden">
                                <label class="col-sm-3 control-label">用户类型</label>
                                <div class="col-sm-8">
                                    <select class="form-control" id="userType">
                                        //动态加载
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">绑定卡号</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="CardNo"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">联系电话</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="Phone"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">终端编号</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="DeviceId"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">安全设备号</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="SafeDevId"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">终端状态</label>
                                <div class="col-sm-8">
                                    <select class="form-control" name="Tel_state">
                                        <option value="">全部</option>
                                        <option value="03">待绑定</option>
                                        <option value="01" selected>正常</option>
                                        <option value="04">待复核</option>
                                        <option value="05">复核未通过</option>
                                        <option value="02">已解绑</option>
                                        <option value="06">已更换</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button id="modal-btn-query" type="submit" class="btn btn-primary" data-dismiss="modal">查询</button> <button id="modal-btn-close1" type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
$(function () {

    /*获取当前角色的按钮权限-Start*/
    var btnHtml ;
    var btnRole = JSON.parse($.cookie("Role_note"));
    btnHtml = '<div class="form-inline" role="form">';
/*
    btnHtml += (btnRole["DataAdd"]) ? '<button id="btn-DataAdd" type="button" role="button" class="subFun btn btn-sm btn-primary">' +
            '<span class="glyphicon glyphicon-plus"></span> 新增</button> ' : '' ;
*/
    btnHtml += (btnRole["DataModify"]) ? '<button id="btn-DataModify" type="button" role="button" class="subFun btn btn-sm btn-Data btn-success disabled">' +
            '<span class="glyphicon glyphicon-pencil"></span> 修改</button> ' : '' ;
    btnHtml += (btnRole["DataConfirm"]) ? '<button id="btn-DataConfirm" type="button" role="button" class="subFun btn btn-sm btn-Data btn-danger disabled">' +
            '<span class="glyphicon glyphicon-check"></span> 复核</button> ' : '' ;
/*
    btnHtml += (btnRole["DataCancel"]) ? '<button id="btn-DataCancel" type="button" role="button" class="subFun btn btn-sm btn-Data btn-danger disabled">' +
            '<span class="glyphicon glyphicon-retweet"></span> 销户</button> ' : '' ;
*/
    /*btnHtml += '<button id="btn-DataDetail" type="button" role="button" class="subFun btn btn-sm btn-Data btn-info disabled">' +
            '<span class="glyphicon glyphicon-th-list"></span> 详情</button> ';*/
    btnHtml += '<button id="btn-DataReplace" type="button" role="button" class="subFun btn btn-sm btn-Data btn-info disabled">' +
            '<span class="glyphicon glyphicon-th-list"></span> 更换</button> ';
/*
    btnHtml += (btnRole["DataBind"]) ? '<button id="btn-DataBind" type="button" role="button" class="subFun btn btn-sm btn-Data btn-success disabled">' +
            '<span class="glyphicon glyphicon-paperclip"></span> 绑定</button> ' : '' ;
*/
    btnHtml += (btnRole["DataUnbind"]) ? '<button id="btn-DataUnbind" type="button" role="button" class="subFun btn btn-sm btn-Data btn-warning disabled">' +
            '<span class="glyphicon glyphicon-log-out"></span> 解绑</button> ' : '' ;
    btnHtml += '<button id="btn-Filter" type="button" href="#modal-Filter" role="button" data-toggle="modal" class="btn btn-sm btn-primary pull-right" title="请选择数据">' +
            '<span class="glyphicon glyphicon-th-list"></span> 筛选</button></div>';

    $("#custom-toolbar").append(btnHtml);
    /*获取当前角色的按钮权限-End*/


    $('#table').bootstrapTable({
        queryParams:function(params) {
            var qp={
                page:params.offset/params.limit+1,
                rows:params.limit
            };
            return qp;
        },
        data:[],
        sidePagination: 'server',
        pagination:true,
        pageSize:10,
        search:false,
        responseHandler:function(data){
            return data.data;
        }
    })
        .on('click-row.bs.table', function (e, row, $element) {
            if ( $element.hasClass('selected') ) {
                $element.removeClass('info');
            }
            else {
                $element.parent('tbody').find(' > tr.selected ').removeClass("info");
                $element.addClass('info');
            }
        })
        .on('check.bs.table', function (e, row, $element) {
            $(".btn-Data").removeClass("disabled");
        })
        .on('uncheck.bs.table', function (e, row, $element) {
            $(".btn-Data").addClass("disabled");
        });


    /*筛选框下拉列表数据初始化-Start*/
    OrgSelectInit();
    FormatSelect(globalUrl+"api/Dict?Typeid=0000000007",$("#userType"),"全部","",function(){
        $('#modal-Filter').modal('show');
    });
    /*筛选框下拉列表数据初始化-End*/


    /*筛选框查询按钮点击事件注册-Start*/
    $("#modal-btn-query").click(function(e){
        $("#OrgId").val(localStorage.orgid);
        $(".btn-Data").addClass("disabled");
        $('#table').bootstrapTable("destroy");
        $('#table').bootstrapTable({
            queryParams:function(params) {
                var qp={
                    page:params.offset/params.limit+1,
                    rows:params.limit
                };
                return qp;
            },
            url:globalUrl+"api/DeviCustomer?"+$("#queryForm").serialize(),
            sidePagination: 'server',
            pagination:true,
            pageSize:10,
            search:false,
            responseHandler:function(data){
                return data.data;
            }
        })
            .on('click-row.bs.table', function (e, row, $element) {
                    if ( $element.hasClass('selected') ) {
                        $element.removeClass('info');
                    }
                    else {
                        $element.parent('tbody').find(' > tr.selected ').removeClass("info");
                        $element.addClass('info');
                    }
                })
            .on('check.bs.table', function (e, row, $element) {
                    $(".btn-Data").removeClass("disabled");
                })
            .on('uncheck.bs.table', function (e, row, $element) {
                    $(".btn-Data").addClass("disabled");
                });
    });
    /*筛选框查询按钮点击事件注册-End*/


    /*子功能按钮事件注册-Start*/
    $('.subFun').on("click",function () {

        var fileName=$(this).attr("id").substr(8);
        var url="../assets/tpls/DeviceInfo_"+fileName+".html";

        getTpls(url,function(resp){

            $("#modal-Template").html(resp);

            //表格中选中行的数据绑定到当前功能模版
            dataBindToModal($('#validForm'),$('#table'));
            //alert($("#FeesCharged").val()==="0");
            if($("#FeesCharged").val()==="0"){
                $("#FeeFixedAmt").parent().parent().removeClass("hidden");
            }else{
                $("#FeeFixedAmt").parent().parent().addClass("hidden");
            }
            var PId=$("#PId").val();
            var SafeDevId=$("#SafeDevId").val();
            var DeviceId=$("#DeviceId").val();
            switch (fileName){
                case "Modify":
                   /* $("#SafeDevId").val(PadId);*/
                    $('#modal-Template').modal('show');
                    $("#OrgId").val($('#table').bootstrapTable('getSelections')[0].OrgId);
                    var IsKh = $('#table').bootstrapTable('getSelections')[0].IsKh;
                    if(IsKh=='01'){
                        $("#IsKh").prop("checked",true).val("01");
                    }else{
                        $("#IsKh").prop("checked",false).val("00");
                    }

                    if($("#Merchant_id").val()!=''){
                        $(".IsKh").removeClass("KhHide");
                    }
                    $("#IsKh").click(function(){
                        var value = ($(this).prop("checked")) ? "01" : "00";
                        $("#IsKh").val(value);
                    });

                    $("#FeesCharged").change(function(){
                        if($(this).val()==="0")
                        {
                            $("#FeeFixedAmt").parent().parent().css("display","block");
                            $.ajax({
                                type: "get",
                                dataType: "json",
                                url:globalUrl+"api/UserType?Usertype="+$("#UserType").val(),
                                success:function(resp){
                                    $("#FeeFixedAmt").attr("min",resp.data.FactorageMin).attr("max",resp.data.FactorageMax).attr("placeHolder","取值区间为：["+resp.data.FactorageMin+"～"+resp.data.FactorageMax+"]");
                                    //$("#validForm").data('formValidation').destroy();
                                }
                            });
                        }
                        else
                        {
                            $("#FeeFixedAmt").val("");
                            $("#FeeFixedAmt").parent().parent().css("display","none");
                        }
                    });
                    var proCardNo=$("#CardNo").val();
                    //$("#validForm").data('formValidation').destroy();
                    /*                            $("#CusLmtAmt").attr("max",$("#CusLmtAmt").val());
                     $("#CusLmtAmtDay").attr("max",$("#CusLmtAmtDay").val());
                     $("#CusOtherLmtAmt").attr("max",$("#CusOtherLmtAmt").val());
                     $("#CusOtherLmtAmtDay").attr("max",$("#CusOtherLmtAmtDay").val());*/
                    $.ajax({
                        url:globalUrl+"api/UserType?UserType="+$("#UserType").val(),
                        success:function(resp)
                        {
                            if(resp.result)
                            {
                                $("#CusLmtAmt").val(resp.data.LmtAmt).attr("max",resp.data.LmtAmt);
                                $("#CusLmtAmtDay").val(resp.data.LmtAmtDay).attr("max",resp.data.LmtAmtDay);
                                $("#CusOtherLmtAmt").val(resp.data.OtherLmtAmt).attr("max",resp.data.OtherLmtAmt);
                                $("#CusOtherLmtAmtDay").val(resp.data.OtherLmtAmtDay).attr("max",resp.data.OtherLmtAmtDay);
                            }
                            else
                            {
                                alert(resp.msg);
                            }
                        }
                    });
                    $('#validForm')
                            .formValidation({
                                err: {
                                    container: 'popover'
                                },
                                icon: {
                                    valid: 'glyphicon glyphicon-ok',
                                    invalid: 'glyphicon glyphicon-remove',
                                    validating: 'glyphicon glyphicon-refresh'
                                }
                            })
                            .on('success.form.fv', function(e) {
                                e.preventDefault();
                                if(parseInt($("#CusLmtAmt").val())>parseInt($("#CusLmtAmtDay").val()))
                                {
                                    alert("单笔限额应小于日累计限额");
                                    return;
                                }
                                if(parseInt($("#CusOtherLmtAmt").val())>parseInt($("#CusOtherLmtAmtDay").val()))
                                {
                                    alert("单笔跨行限额应小于日累计跨行限额");
                                    return;
                                }
                                $.ajax({
                                    type: "post",
                                    data:$('#validForm').serializeArray(),
                                    url: globalUrl+"api/Device?proCardNo="+proCardNo+"&PId="+PId,
                                    success: function (resp){
                                        if(resp.result)
                                        {
                                            alert("操作成功！");
                                            $('#modal-Template').modal('hide');
                                            $("#OrgId").val(localStorage.orgid);
                                            $('#table').bootstrapTable('refresh',{url:globalUrl+"api/Device?"+$("#queryForm").serialize()});
                                            $(".btn-Data").addClass("disabled");
                                            $("#btn-DataAdd").removeClass("disabled");
                                        }
                                        else
                                        {
                                            alert(resp.msg);
                                        }
                                    },
                                    error:function(){
                                        alert("后台未成功返回！");
                                    }
                                });
                            });


                    break;
                case "Confirm":
                    var Tel_State=$('#table').bootstrapTable('getSelections')[0].Tel_State;
                    if(Tel_State!="04")
                 {
                 alert("非法操作，当前用户状态不允许复核！");
                 return;
                 }
                    $('#modal-Template').modal('show');

                    ///2015.03.27 By Phoenix Add 增加填写复核结果
                    $("#ConfirmNoteSel").change(function(){
                        if($(this).val()=="99")
                        {
                            $("#ConfirmNote").val("");
                            $("#ConfirmNote").parent().parent().removeClass("hidden");
                        }
                        else if($(this).val()!="")
                        {
                            $("#ConfirmNote").val($(this).find("option:selected").text());
                            $("#ConfirmNote").parent().parent().addClass("hidden");
                        }
                        else
                        {
                            $("#ConfirmNote").val("");
                            $("#ConfirmNote").parent().parent().addClass("hidden");
                        }
                        $('#validForm').data('formValidation').resetForm();
                    });
                    $('#validForm')
                            .formValidation({
                                err: {
                                    container: 'popover'
                                },
                                icon: {
                                    valid: 'glyphicon glyphicon-ok',
                                    invalid: 'glyphicon glyphicon-remove',
                                    validating: 'glyphicon glyphicon-refresh'
                                }
                            })
                            .on('success.form.fv', function(e) {
                                e.preventDefault();
                                var ConfirmNoteSel = $("#ConfirmNoteSel").val();
                                var ConfirmNote = encodeURIComponent($("#ConfirmNote").val());
                                $.ajax({
                                    type: "get",
                                    url: globalUrl+"api/Device?SafeDevId="+SafeDevId+"&ConfirmNoteSel="+ConfirmNoteSel+"&ConfirmNote="+ConfirmNote,
                                    success: function (resp) {
                                        if(resp.result)
                                        {
                                            alert(resp.msg);
                                            $('#modal-Template').modal('hide');
                                            $("#OrgId").val(localStorage.orgid);
                                            $('#table').bootstrapTable('refresh',{url:globalUrl+"api/DeviCustomer?"+$("#queryForm").serialize()});
                                            $(".btn-Data").addClass("disabled");
                                        }
                                        else
                                        {
                                            alert(resp.msg);
                                        }
                                    },
                                    error:function(){
                                        alert("后台未成功返回！");
                                    }
                                });
                            });
                    break;
                case "Replace":
                    $("#NewDeviceId").click(function(){
                        var termId = P_UploadTermID();
                        if(!termId)
                        {
                            return;
                        }
                        var padId = P_UploadSafeID();
                        if(!padId)
                        {
                            return;
                        }
                        $("#NewDeviceId").val(termId);
                        $("#NewSafeDevId").val(padId);
                    });
                    var Tel_State=$('#table').bootstrapTable('getSelections')[0].Tel_State;
                    /*if(Tel_State!="04")
                    {
                        alert("非法操作，当前用户状态不允许复核！");
                        return;
                    }*/
                    $('#modal-Template').modal('show');
                    $('#validForm')
                            .formValidation({
                                err: {
                                    container: 'popover'
                                },
                                icon: {
                                    valid: 'glyphicon glyphicon-ok',
                                    invalid: 'glyphicon glyphicon-remove',
                                    validating: 'glyphicon glyphicon-refresh'
                                }
                            })
                            .on('success.form.fv', function(e) {
                                e.preventDefault();
                                $.ajax({
                                    type: "get",
                                    url: globalUrl+"api/DeviCustomer?SafeDevId="+SafeDevId+"&DeviceId="+DeviceId+"&PId="+PId+"&NewDeviceId="+$("#NewDeviceId").val()+"&NewSafeDevId="+$("#NewSafeDevId").val(),
                                    success: function (resp) {
                                        if(resp.result)
                                        {
                                            alert(resp.msg);
                                            $('#modal-Template').modal('hide');
                                            /*$("#OrgId").val(localStorage.orgid);*/
                                            $('#table').bootstrapTable('refresh',{url:globalUrl+"api/DeviCustomer?"+$("#queryForm").serialize()});
                                            $(".btn-Data").addClass("disabled");
                                        }
                                        else
                                        {
                                            alert(resp.msg);
                                        }
                                    },
                                    error:function(){
                                        alert("后台未成功返回！");
                                    }
                                });
                            });
                    break;
                    ///
                    /*$('#modal-btn-Confirm').click(function (e) {
                        e.preventDefault();
                        $.ajax({
                            type: "get",
                            url: globalUrl+"api/Device?SafeDevId="+PadId,
                            success: function (resp) {
                                if(resp.result)
                                {
                                    alert("操作成功！");
                                    $('#modal-Template').modal('hide');
                                    $("#OrgId").val(localStorage.orgid);
                                    $('#table').bootstrapTable('refresh',{url:globalUrl+"api/Device?"+$("#queryForm").serialize()});
                                    $(".btn-Data").addClass("disabled");
                                }
                                else
                                {
                                    alert(resp.msg);
                                }
                            },
                            error:function(){
                                alert("后台未成功返回！");
                            }
                        });
                    });
                    break;*/
                case "Unbind":
                    var Tel_State=$('#table').bootstrapTable('getSelections')[0].Tel_State;
                    if(Tel_State!="01")
                    {
                        alert("非法操作，当前用户状态不允许解绑！");
                        return;
                    }
                    var IsKh = $('#table').bootstrapTable('getSelections')[0].IsKh;
                    var Merchant_id = $.trim($('#table').bootstrapTable('getSelections')[0].Merchant_id);
                    if(IsKh=='01'){
                        $("#IsKh").prop("checked",true).val("01");
                    }else{
                        $("#IsKh").prop("checked",false).val("00");
                    }
                    if(Merchant_id!=''){
                        $(".IsKh").removeClass("KhHide");
                    }
                    $('#modal-Template').modal('show');

                    ///2015.03.26 By Phoenix Add 增加填写销户原因
                    $("#DeleteNoteSel").change(function(){
                        if($(this).val()=="99")
                        {
                            $("#DeleteNote").val("");
                            $("#DeleteNote").parent().parent().removeClass("hidden");
                        }
                        else if($(this).val()!="")
                        {
                            $("#DeleteNote").val($(this).find("option:selected").text());
                            $("#DeleteNote").parent().parent().addClass("hidden");
                        }
                        else
                        {
                            $("#DeleteNote").val("");
                            $("#DeleteNote").parent().parent().addClass("hidden");
                        }
                        $('#validForm').data('formValidation').resetForm();
                    });
                    $('#validForm')
                            .formValidation({
                                err: {
                                    container: 'popover'
                                },
                                icon: {
                                    valid: 'glyphicon glyphicon-ok',
                                    invalid: 'glyphicon glyphicon-remove',
                                    validating: 'glyphicon glyphicon-refresh'
                                }
                            })
                            .on('success.form.fv', function(e) {
                                e.preventDefault();
                                var DeleteNoteSel = $("#DeleteNoteSel").val();
                                var DeleteNote = encodeURIComponent($("#DeleteNote").val());
                                var SafeDevId=$("#SafeDevId").val();
                                var DeviceId=$("#DeviceId").val();
                                $.ajax({
                                    type: "get",
                                    url: globalUrl+"api/DeviCustomer?SafeDevId="+SafeDevId+"&pid="+PId+"&DeviceId="+DeviceId+"&DeleteNoteSel="+DeleteNoteSel+"&DeleteNote="+DeleteNote,
                                    success: function (resp) {
                                        if(resp.result)
                                        {
                                            alert("操作成功！");
                                            console.log(resp);
                                            $('#modal-Template').modal('hide');
                                            $("#OrgId").val(localStorage.orgid);
                                            $('#table').bootstrapTable('refresh',{url:globalUrl+"api/DeviCustomer?"+$("#queryForm").serialize()});
                                            $(".btn-Data").addClass("disabled");
                                            $("#btn-DataAdd").removeClass("disabled");
                                        }
                                        else
                                        {
                                            alert(resp.msg);
                                        }
                                    },
                                    error:function(){
                                        alert("后台未成功返回！");
                                    }
                                });
                            });
                    break;
                    ///
                    /*$('#modal-btn-Unbundling').click(function (e) {
                        e.preventDefault();
                        $.ajax({
                            type: "get",
                            url: globalUrl+"api/DeviCustomer?PadId="+PadId+"&pid="+PId+"&TermId="+TermId,
                            success: function (resp) {
                                if(resp.result)
                                {
                                    alert("操作成功！");
                                    console.log(resp);
                                    $('#modal-Template').modal('hide');
                                    $("#OrgId").val(localStorage.orgid);
                                    $('#table').bootstrapTable('refresh',{url:globalUrl+"api/Device?"+$("#queryForm").serialize()});
                                    $(".btn-Data").addClass("disabled");
                                    $("#btn-DataAdd").removeClass("disabled");
                                }
                                else
                                {
                                    alert(resp.msg);
                                }
                            },
                            error:function(){
                                alert("后台未成功返回！");
                            }
                        });
                    });
                    break;*/
                case "Detail":
                    var IsKh = $('#table').bootstrapTable('getSelections')[0].IsKh;
                    var Merchant_id = $.trim($('#table').bootstrapTable('getSelections')[0].Merchant_id);
                    if(IsKh=='01'){
                        $("#IsKh").prop("checked",true).val("01");
                    }else{
                        $("#IsKh").prop("checked",false).val("00");
                    }
                    if(Merchant_id!=''){
                        $(".IsKh").removeClass("KhHide");
                    }
                    $('#modal-Template').modal('show');
                    break;
                default:
            }


        });
    });
    /*子功能按钮事件注册-End*/
});
//读取终端序列号
function P_UploadTermID() {
    if(P_CloseCOMport()!="0000")
    {
        alert("关闭串口出错");
        return false;
    }
    //打开串口
    P_OpenCOMport();
    var a = NDV_OCX.UploadTermID();
    if(P_CloseCOMport()!="0000")
    {
        alert("关闭串口出错");
        return false;
    }
    if (a != "" && a != undefined && a != '0014') {
        return a;
    } else {
        alert(a+" 读取终端序列号失败");
        return false;
    }
}

//读取密码键盘序列号
function P_UploadSafeID() {
    if(P_CloseCOMport()!="0000")
    {
        alert("关闭串口出错");
        return false;
    }
    //打开串口
    P_OpenCOMport();
    var a = NDV_OCX.UploadSafeID();
    if(P_CloseCOMport()!="0000")
    {
        alert("关闭串口出错");
        return false;
    }
    if (a != "" && a != undefined && a != '0015') {
        return a;
    } else {
        alert(a+" 读取密码键盘序列号失败");
        return false;
    }

}

//关闭串口
function P_CloseCOMport() {
    return NDV_OCX.CloseCOMport();
}

//打开串口
function P_OpenCOMport() {
    //寻址打开串口
    for (var i = 0; i < 10; i++) {
        var openco = NDV_OCX.OpenCOMport("COM" + i, "9600");
        if (openco == '0000') {
            break;
        }
    }
}
</script>